"""
基础数据模型类

"""
from datetime import datetime

from peewee import Model, BooleanField, AutoField, DateTimeField

from components.mysql.connector import db


class MetaBaseModel(Model):
    """
    基类
    """
    class Meta:
        database = db


class BaseModel(MetaBaseModel):
    """
    基础数据模型类
    属性：
        create_time: int类型,创建时间
        is_del: 布尔类型,是否软删除
    """
    id = AutoField(primary_key=True)
    create_time = DateTimeField(default=datetime.now, verbose_name="创建时间")
    is_del = BooleanField(default=False)

    def get_fields(self):
        res = [field for field in self._meta.fields]
